package com.superteam.zzl.viewmodel.Search;

import android.util.Log;

import com.superteam.zzl.activity.SearchMoreActivity.DynMoreActivity;
import com.superteam.zzl.activity.SearchMoreActivity.PoiMoreActivity;
import com.superteam.zzl.activity.SearchMoreActivity.ShopMoreActivity;
import com.superteam.zzl.activity.SearchMoreActivity.UserMoreActivity;
import com.superteam.zzl.app.MyApplication;
import com.superteam.zzl.cans.ContentURLs;
import com.superteam.zzl.model.Search.DynData;
import com.superteam.zzl.model.Search.GropData;
import com.superteam.zzl.model.Search.LoadMoreData;
import com.superteam.zzl.model.Search.PoiData;
import com.superteam.zzl.model.Search.SearchMoreData;
import com.superteam.zzl.model.Search.ShopData;
import com.superteam.zzl.model.Search.UserData;

import java.util.ArrayList;

/**
 * Created by zhang on 2017/1/14.
 */

public class RequestMoreData implements SearchMoreData {

    private DynData dynData;
    private ShopData shopData;
    private PoiData poiData;
    private UserData userData;
    private GropData gropData;
    private LoadMoreData loadMoreData;
    private int pageIndex;

    public RequestMoreData(DynData dynData,int pageIndex) {
        this.dynData = dynData;
        this.pageIndex = pageIndex;
        //Log.e("data","RequestMore");
        String url = ContentURLs.result_before+"trend/"+MyApplication.search+"/"+pageIndex+""+ContentURLs.result_after;
        loadMoreData = new LoadMoreData(this,url,1);
    }

    public RequestMoreData(ShopData shopData,int pageIndex) {
        this.shopData = shopData;
        this.pageIndex = pageIndex;
        String url = ContentURLs.result_before+"product/"+MyApplication.search+"/"+pageIndex+""+ContentURLs.result_after;
        loadMoreData = new LoadMoreData(this,url,2);
    }

    public RequestMoreData(PoiData poiData,int pageIndex) {
        this.pageIndex = pageIndex;
        this.poiData = poiData;
        String url = ContentURLs.result_before+"poi/"+MyApplication.search+"/"+pageIndex+""+ContentURLs.result_after;
        loadMoreData = new LoadMoreData(this,url,3);
    }

    public RequestMoreData(UserData userData,int pageIndex) {
        this.userData = userData;
        this.pageIndex = pageIndex;
        String url = ContentURLs.result_before+"user/"+MyApplication.search+"/"+pageIndex+""+ContentURLs.result_after;
        loadMoreData = new LoadMoreData(this,url,4);
    }

    public RequestMoreData(GropData gropData) {
        this.gropData = gropData;
    }

    public RequestMoreData() {
    }

    @Override
    public void sendDyn(ArrayList<DynData.TrendListBean> dynDatas) {
        //Log.e("data",dynDatas.size()+"");
        //Log.e("data",dynData.toString()+"");
//        for (int i = 0; i < dynDatas.size(); i++) {
//            //Log.e("data",dynDatas.get(i).getContent());
//            dynData.trendLists=dynDatas;
//        }
        dynData.trendLists = dynDatas;
        DynMoreActivity.handler.sendEmptyMessage(0x001);
    }

    @Override
    public void sendShop(ArrayList<ShopData.ProductListBean> shopDatas) {
        shopData.productLists = shopDatas;
        //Log.e("data","shopdata"+shopData.productLists.size());
        ShopMoreActivity.handler.sendEmptyMessage(0x002);
    }

    @Override
    public void sendPoi(ArrayList<PoiData.PoiListBean> poiDatas) {
        poiData.poiLists = poiDatas;
        PoiMoreActivity.handler.sendEmptyMessage(0x003);
    }

    @Override
    public void sendUser(ArrayList<UserData.UserListBean> userDatas) {
        userData.userLists = userDatas;
        UserMoreActivity.handler.sendEmptyMessage(0x004);
    }

    @Override
    public void sengGrop(ArrayList<GropData.GroupListBean> gropDatas) {

    }
}
